import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class PersonMan {
    private String name;
    private int age;
    private String car;
    private String house;
    private double savings;

    // 构造函数注入
    public PersonMan(String name, int age, String car, String house, double savings) {
        this.name = name;
        this.age = age;
        this.car = car;
        this.house = house;
        this.savings = savings;
    }

    // 默认构造函数
    public PersonMan() {}

    // 属性注入
    public void setName(String name) {
        this.name = name;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void setCar(String car) {
        this.car = car;
    }

    public void setHouse(String house) {
        this.house = house;
    }

    public void setSavings(double savings) {
        this.savings = savings;
    }

    @Override
    public String toString() {
        return "PersonMan{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", car='" + car + '\'' +
                ", house='" + house + '\'' +
                ", savings=" + savings +
                '}';
    }

    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");

        // 使用属性注入的PersonMan对象
        PersonMan personMan1 = (PersonMan) context.getBean("personMan1");
        System.out.println(personMan1);

        // 使用构造函数注入的PersonMan对象
        PersonMan personMan2 = (PersonMan) context.getBean("personMan2");
        System.out.println(personMan2);
    }
}
